package com.maodou.core.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

/**
 * 字体排版系统
 * 提供多种字体大小和样式定义
 */

// ==================== 字体大小定义 ====================

object FontSizes {
    // 超小字体
    val ExtraSmall = 10.sp
    
    // 小字体
    val Small = 12.sp
    
    // 正文字体
    val Body = 14.sp
    val BodyLarge = 16.sp
    
    // 标题字体
    val Title = 18.sp
    val TitleMedium = 20.sp
    val TitleLarge = 22.sp
    
    // 大标题字体
    val Headline = 24.sp
    val HeadlineMedium = 28.sp
    val HeadlineLarge = 32.sp
    
    // 展示字体
    val Display = 36.sp
    val DisplayMedium = 45.sp
    val DisplayLarge = 57.sp
}

// ==================== 行高定义 ====================

object LineHeights {
    val ExtraSmall = 14.sp
    val Small = 16.sp
    val Body = 20.sp
    val BodyLarge = 24.sp
    val Title = 24.sp
    val TitleMedium = 28.sp
    val TitleLarge = 32.sp
    val Headline = 32.sp
    val HeadlineMedium = 36.sp
    val HeadlineLarge = 40.sp
    val Display = 44.sp
    val DisplayMedium = 52.sp
    val DisplayLarge = 64.sp
}

// ==================== 字符间距定义 ====================

object LetterSpacings {
    val Tight = (-0.25).sp
    val Normal = 0.sp
    val Relaxed = 0.25.sp
    val Wide = 0.5.sp
    val ExtraWide = 1.sp
}

// ==================== 基础字体样式 ====================

object BaseTextStyles {
    // 展示级别文本样式
    val DisplayLarge = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.DisplayLarge,
        lineHeight = LineHeights.DisplayLarge,
        letterSpacing = LetterSpacings.Tight
    )
    
    val DisplayMedium = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.DisplayMedium,
        lineHeight = LineHeights.DisplayMedium,
        letterSpacing = LetterSpacings.Normal
    )
    
    val DisplaySmall = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.Display,
        lineHeight = LineHeights.Display,
        letterSpacing = LetterSpacings.Normal
    )
    
    // 标题级别文本样式
    val HeadlineLarge = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.HeadlineLarge,
        lineHeight = LineHeights.HeadlineLarge,
        letterSpacing = LetterSpacings.Normal
    )
    
    val HeadlineMedium = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.HeadlineMedium,
        lineHeight = LineHeights.HeadlineMedium,
        letterSpacing = LetterSpacings.Normal
    )
    
    val HeadlineSmall = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.Headline,
        lineHeight = LineHeights.Headline,
        letterSpacing = LetterSpacings.Normal
    )
    
    // 标题级别文本样式
    val TitleLarge = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Medium,
        fontSize = FontSizes.TitleLarge,
        lineHeight = LineHeights.TitleLarge,
        letterSpacing = LetterSpacings.Normal
    )
    
    val TitleMedium = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Medium,
        fontSize = FontSizes.TitleMedium,
        lineHeight = LineHeights.TitleMedium,
        letterSpacing = LetterSpacings.Relaxed
    )
    
    val TitleSmall = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Medium,
        fontSize = FontSizes.Title,
        lineHeight = LineHeights.Title,
        letterSpacing = LetterSpacings.Relaxed
    )
    
    // 正文级别文本样式
    val BodyLarge = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.BodyLarge,
        lineHeight = LineHeights.BodyLarge,
        letterSpacing = LetterSpacings.Wide
    )
    
    val BodyMedium = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.Body,
        lineHeight = LineHeights.Body,
        letterSpacing = LetterSpacings.Relaxed
    )
    
    val BodySmall = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Normal,
        fontSize = FontSizes.Small,
        lineHeight = LineHeights.Small,
        letterSpacing = LetterSpacings.Relaxed
    )
    
    // 标签级别文本样式
    val LabelLarge = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Medium,
        fontSize = FontSizes.Body,
        lineHeight = LineHeights.Body,
        letterSpacing = LetterSpacings.Relaxed
    )
    
    val LabelMedium = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Medium,
        fontSize = FontSizes.Small,
        lineHeight = LineHeights.Small,
        letterSpacing = LetterSpacings.Wide
    )
    
    val LabelSmall = TextStyle(
        fontFamily = FontFamily.Default,
        fontWeight = FontWeight.Medium,
        fontSize = FontSizes.ExtraSmall,
        lineHeight = LineHeights.ExtraSmall,
        letterSpacing = LetterSpacings.Wide
    )
}

// ==================== 默认字体排版 ====================

/**
 * 默认字体排版配置
 * 基于 Material Design 3 规范
 */
val DefaultTypography = Typography(
    displayLarge = BaseTextStyles.DisplayLarge,
    displayMedium = BaseTextStyles.DisplayMedium,
    displaySmall = BaseTextStyles.DisplaySmall,
    headlineLarge = BaseTextStyles.HeadlineLarge,
    headlineMedium = BaseTextStyles.HeadlineMedium,
    headlineSmall = BaseTextStyles.HeadlineSmall,
    titleLarge = BaseTextStyles.TitleLarge,
    titleMedium = BaseTextStyles.TitleMedium,
    titleSmall = BaseTextStyles.TitleSmall,
    bodyLarge = BaseTextStyles.BodyLarge,
    bodyMedium = BaseTextStyles.BodyMedium,
    bodySmall = BaseTextStyles.BodySmall,
    labelLarge = BaseTextStyles.LabelLarge,
    labelMedium = BaseTextStyles.LabelMedium,
    labelSmall = BaseTextStyles.LabelSmall
)

// ==================== 紧凑字体排版 ====================

/**
 * 紧凑字体排版配置
 * 适用于信息密度较高的界面
 */
val CompactTypography = Typography(
    displayLarge = BaseTextStyles.DisplayLarge.copy(
        fontSize = FontSizes.DisplayMedium,
        lineHeight = LineHeights.DisplayMedium
    ),
    displayMedium = BaseTextStyles.DisplayMedium.copy(
        fontSize = FontSizes.Display,
        lineHeight = LineHeights.Display
    ),
    displaySmall = BaseTextStyles.DisplaySmall.copy(
        fontSize = FontSizes.HeadlineLarge,
        lineHeight = LineHeights.HeadlineLarge
    ),
    headlineLarge = BaseTextStyles.HeadlineLarge.copy(
        fontSize = FontSizes.HeadlineMedium,
        lineHeight = LineHeights.HeadlineMedium
    ),
    headlineMedium = BaseTextStyles.HeadlineMedium.copy(
        fontSize = FontSizes.Headline,
        lineHeight = LineHeights.Headline
    ),
    headlineSmall = BaseTextStyles.HeadlineSmall.copy(
        fontSize = FontSizes.TitleLarge,
        lineHeight = LineHeights.TitleLarge
    ),
    titleLarge = BaseTextStyles.TitleLarge.copy(
        fontSize = FontSizes.TitleMedium,
        lineHeight = LineHeights.TitleMedium
    ),
    titleMedium = BaseTextStyles.TitleMedium.copy(
        fontSize = FontSizes.Title,
        lineHeight = LineHeights.Title
    ),
    titleSmall = BaseTextStyles.TitleSmall.copy(
        fontSize = FontSizes.BodyLarge,
        lineHeight = LineHeights.BodyLarge
    ),
    bodyLarge = BaseTextStyles.BodyLarge.copy(
        fontSize = FontSizes.Body,
        lineHeight = LineHeights.Body
    ),
    bodyMedium = BaseTextStyles.BodyMedium.copy(
        fontSize = FontSizes.Small,
        lineHeight = LineHeights.Small
    ),
    bodySmall = BaseTextStyles.BodySmall.copy(
        fontSize = FontSizes.ExtraSmall,
        lineHeight = LineHeights.ExtraSmall
    ),
    labelLarge = BaseTextStyles.LabelLarge.copy(
        fontSize = FontSizes.Small,
        lineHeight = LineHeights.Small
    ),
    labelMedium = BaseTextStyles.LabelMedium.copy(
        fontSize = FontSizes.ExtraSmall,
        lineHeight = LineHeights.ExtraSmall
    ),
    labelSmall = BaseTextStyles.LabelSmall.copy(
        fontSize = 9.sp,
        lineHeight = 12.sp
    )
)

// ==================== 宽松字体排版 ====================

/**
 * 宽松字体排版配置
 * 适用于阅读体验优先的界面
 */
val RelaxedTypography = Typography(
    displayLarge = BaseTextStyles.DisplayLarge.copy(
        fontSize = 64.sp,
        lineHeight = 72.sp
    ),
    displayMedium = BaseTextStyles.DisplayMedium.copy(
        fontSize = FontSizes.DisplayLarge,
        lineHeight = LineHeights.DisplayLarge
    ),
    displaySmall = BaseTextStyles.DisplaySmall.copy(
        fontSize = FontSizes.DisplayMedium,
        lineHeight = LineHeights.DisplayMedium
    ),
    headlineLarge = BaseTextStyles.HeadlineLarge.copy(
        fontSize = FontSizes.Display,
        lineHeight = LineHeights.Display
    ),
    headlineMedium = BaseTextStyles.HeadlineMedium.copy(
        fontSize = FontSizes.HeadlineLarge,
        lineHeight = LineHeights.HeadlineLarge
    ),
    headlineSmall = BaseTextStyles.HeadlineSmall.copy(
        fontSize = FontSizes.HeadlineMedium,
        lineHeight = LineHeights.HeadlineMedium
    ),
    titleLarge = BaseTextStyles.TitleLarge.copy(
        fontSize = FontSizes.Headline,
        lineHeight = LineHeights.Headline
    ),
    titleMedium = BaseTextStyles.TitleMedium.copy(
        fontSize = FontSizes.TitleLarge,
        lineHeight = LineHeights.TitleLarge
    ),
    titleSmall = BaseTextStyles.TitleSmall.copy(
        fontSize = FontSizes.TitleMedium,
        lineHeight = LineHeights.TitleMedium
    ),
    bodyLarge = BaseTextStyles.BodyLarge.copy(
        fontSize = FontSizes.Title,
        lineHeight = LineHeights.Title
    ),
    bodyMedium = BaseTextStyles.BodyMedium.copy(
        fontSize = FontSizes.BodyLarge,
        lineHeight = LineHeights.BodyLarge
    ),
    bodySmall = BaseTextStyles.BodySmall.copy(
        fontSize = FontSizes.Body,
        lineHeight = LineHeights.Body
    ),
    labelLarge = BaseTextStyles.LabelLarge.copy(
        fontSize = FontSizes.BodyLarge,
        lineHeight = LineHeights.BodyLarge
    ),
    labelMedium = BaseTextStyles.LabelMedium.copy(
        fontSize = FontSizes.Body,
        lineHeight = LineHeights.Body
    ),
    labelSmall = BaseTextStyles.LabelSmall.copy(
        fontSize = FontSizes.Small,
        lineHeight = LineHeights.Small
    )
)